
cc.Class({
    extends: cc.Component,

    properties: {
		overtop:cc.Node,
		cleartop:cc.Node,
		retry:cc.Node,
		next:cc.Node,
    },

    onLoad () {
		cc.director.on('overclear',(e)=>{
			if(e.detail.type == 'over'){//游戏结束
				this.overtop.active = true;
				this.cleartop.active = false;
				this.next.active = false;
				this.retry.active = true;
			}else{//clear 通关
				this.overtop.active = false;
				this.cleartop.active = true;
				this.next.active = true;
				this.retry.active = false;
			}
		},this);
    },

    btnClick(event,customData) {
		switch(customData){
			case 'retry'://重试本关
				cc.director.emit('ongame','restart');
				this.node.active = false;
				break;
			case 'next'://下一关
				cc.director.emit('ongame','next');
				this.node.active = false;
				break;
			case 'top'://回到主界面
				//cc.director.emit('ongame','endcurrent');
				//此处应该用渐隐效果
				cc.director.getScheduler().schedule(() => {
					this.node.opacity -= 5;
					
				}, this, 1/51, 50);
				
				cc.director.loadScene('main');
				
				//this.node.active = false;
				cc.director.emit('returntomain');
				break;
			default:
				break;
		}
	},

    // update (dt) {},
});
